package common

import (
	"gin/pkg"

	"github.com/jinzhu/gorm"
)

//连接数据库
func Conn() *gorm.DB {
	db, err := gorm.Open("postgres", " port=5432 user=postgres dbname=familytree password=postgre sslmode=disable")
	pkg.ErrCheck(err)
	db.SingularTable(true)
	return db
}

/*func Conn() *sql.DB {
	psqlInfo := fmt.Sprintf("host=%s port=%d user=%s "+
		"password=%s dbname=%s sslmode=disable",
		host, port, user, password, dbname)
	db, err := sql.Open("postgres", psqlInfo)
	if err != nil {
		panic(err)
	}
	err = db.Ping()
	if err != nil {
		panic(err)
	}
	fmt.Println("Successfully connected!")
	return db
}*/
